<?php
$messages = user()->getNotifications();
if ( !empty($messages) ) : ?>
<script type="text/javascript">
	$(function() {
	<?php foreach ($messages as $message) :
		$html = '<div id="'.$message['key'].'" class="message-'.$message['type'].'">'.$message['message'].'</div>';
		$title = t('Message');

		switch ($message['type'] ) {
			case 'E':
				$type = 'error';
				break;
			case 'N':
				$type = 'information';
				break;
			case 'W':
				$type = 'warning';
				break;
		}

		$title = t($type);
		?>
		cm_dialog('<?php echo $title ?>', '<?php echo $message['message'] ?>', {
			type: '<?php echo $type ?>',
			width: 450
		});
	<?php endforeach; ?>

	});
</script>

<?php endif;